package fragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

import entity.Animation;

public class MobilePagerAdapter extends FragmentPagerAdapter {
    private final List<Animation> list;
    public MobilePagerAdapter(@NonNull FragmentManager fm, List<Animation> info) {
        super(fm,BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.list = info;
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        Animation animation = list.get(position);
        return FragmentDynamic.newInstance(position,animation.getPic(),animation.getDescription());
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
       return list.get(position).getTitle();
    }
}
